<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);

pc_base::load_app_func('global');
class ushop extends admin {
	private $db;

	function __construct() {
		parent::__construct();
		pc_base::load_sys_class('form');
		pc_base::load_app_class('Fusion_Image');
	}
	
	function init(){
		echo '商城系统';
	}
	public function setting() {
		$module_db = pc_base::load_model('module_model');
		if (isset($_POST['dosubmit'])) {
			$_POST['setting']['priv'] = $_POST['priv'];
			$setting = array2string($_POST['setting']);
			$module_db->update(array('setting'=>$setting), array('module'=>'ushop'));
 			setcache('ushop_setting', $_POST['setting']);
			if($_POST['setting']['isdomain']=='1'){
				$shopdomain = $_POST['setting']['domain'];
				$route_config = pc_base::load_config('route');
				$route_config["$shopdomain"]=array('m'=>'ushop','c'=>'index','a'=>'init');
				$data = "<?php\nreturn ".var_export($route_config, true).";\n?>";
				$path = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.'route.php';
				file_put_contents($path,$data);				
				}	
  			showmessage(L('operation_success'), HTTP_REFERER);
		} else {
			$show_header = true;
			pc_base::load_sys_class('form', '', '');
			$setting = $module_db->get_one(array('module'=>'ushop'), 'setting');
			$setting = string2array($setting['setting']);
			$show_validator = 1;		
 			include $this->admin_tpl('ushop_setting');
		}
	}

}
?>